﻿#pragma once

#include "Render/PreRender/PreRenderWidgets.h"
#include "Render/Widget/CharUniformBufferData.h"

class CVulkanWindow;
class CVulkanUniformBuffer;
class CVulkanTexture2D;

class CVulkanTextWidget
{
public:
    void BindData(const SPreRenderTextWidget& InData);
   
    void Draw(vk::CommandBuffer CommandBuffer);

    void CountDescriptorNum();
protected:
    //深度
    float Depth=0.0f;

    //视口
    vk::Viewport Viewport;

    //裁剪,最少一个裁剪矩形，否则会使用上一个元素的裁剪矩形
    //单位是像素
    vk::Rect2D Scissor;

    //存放所有的文字图片
    std::shared_ptr<CVulkanTexture2D> TextImage;
   
    //每个字符的数据
    TVector<SCharUniformBufferData> CharData;


    //这个缓冲区存放所有的字符的数据
    std::shared_ptr<CVulkanUniformBuffer> UniformBuffer;

    //每个批次会被分成固定大小的小批次
    //每个小批次对应一个描述符
    TVector<vk::DescriptorSet> DescriptorSets;

};

//绘制所有的图片控件
class CVulkanTextWidgets
{
public:
    ~CVulkanTextWidgets();

    void PreProcess(const TVector<SPreRenderTextWidget>& AllTextData);

    void CreateSelfRecordTasks(CVulkanWindow *InRenderSurface
        ,SRenderCommandBuffers &OutCmdBuffersToExecute);
protected:
    TVector<CVulkanTextWidget> TextWidgets;

    vk::CommandBuffer CommandBuffer;
};
